﻿
Sys.Application.add_load(ApplicationLoadHandler)

var blocked = 0;

function ApplicationLoadHandler(sender, args) {

    Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(DisplayAsyncPostBackNotification);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(HideAsyncPostBackNotification);
}
function DisplayAsyncPostBackNotification(sender, args) {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (blocked == 0 && (prm.get_isInAsyncPostBack() || prm._postBackSettings.async)) {
        blocked = 1;
        ShowOverlayOnPage();
    }
}
function HideAsyncPostBackNotification(sender, args) {

        blocked = 0;
        $.unblockUI();
}

function ShowOverlayOnPage()
{
    $.blockUI({ baseZ: 40000, message: null, fadeOut: 0, overlayCSS: { opacity: '0.1'} });
}

if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();